package com.caosong.raptor.sso.controller;

import com.caosong.raptor.blog.article.proto.HelloReply;
import com.caosong.raptor.blog.article.proto.HelloRequest;
import com.caosong.raptor.blog.article.proto.HelloRpcService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/hello")
public class HelloController {

    @DubboReference(check = false,version ="1.0.0",protocol = "tri")
    private HelloRpcService helloServiceRpc;

    @RequestMapping(path = "/helloTestRpc",method = RequestMethod.GET)
    public String helloTestRpc(){
        HelloRequest.Builder helloRequestBuilder = HelloRequest.newBuilder();
        HelloRequest helloRequest = helloRequestBuilder.setName("allen-cao").build();
        HelloReply helloReply =  helloServiceRpc.helloService(helloRequest);
        return helloReply.getMessage();
    }
}
